/*
2021-8-29
https://leetcode-cn.com/problems/number-of-unique-good-subsequences/
*/
class Solution {
public:
    int numberOfUniqueGoodSubsequences(string binary) {
        int mod=1e9+7,have0=0;
        int n=binary.size();
        int dp1=0,dp0=0;

        int res=0;
        for(int i=n-1;i>=0;i--)
        {
            if(binary[i]=='0')
            {
                have0=1;
                dp0=(dp0+dp1+1)%mod;
            }
            else
            {
                dp1=(dp1+dp0+1)%mod;
            }
        }
        return (dp1+have0)%mod;
    }
};

